<template>
  <div class="life">
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="time" align="center" label="时间" />
      <el-table-column prop="couent" align="center" label="标题">
        <template slot-scope="scope">{{ scope.row.couent }}</template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button size="medium" type="success" @click="handleClick(scope.row)">查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-col :span="24" class="toolbar" style="text-align: center;">
      <el-pagination
        background
        :current-page="currentPage"
        :page-count="pageNum"
        :page-size="pagesize"
        style="margin-top:30px;margin-bottom:30px"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-col>
  </div>
</template>
<script>
export default {
  data() {
    return {
      currentPage: 1, // 初始页
      pagesize: 10, // 当前页面内的列表行数
      pageCount: 1,
      pageNum: 1, // 页数
      total: 1,
      tableData: [
        {
          time: '2019-12-11',
          couent: '《生活小妙招》'
        }
      ]
    }
  },
  mounted() {},
  methods: {
    handleClick(row) {
      this.$router.push({ name: '生活知识详情', params: { data: row }})
    },
    // 当前页
    handleSizeChange: function(pagesize) {
      this.pagesize = pagesize
    },
    // 换页：更新列表数据
    handleCurrentChange: function(currentPage) {
      this.currentPage = currentPage
    }
  }
}
</script>
<style lang="scss" scoped>
.life {
  margin-top: 55px;
}
</style>
